feat(query-api): add Count and Frequency endpoints for Profiles and P…#23
Merged
Conversation
…romotions APIs - Add GET /profiles/count with profile_type filter - Add GET /profiles/frequency returning counts by ProfileType - Add GET /promotions/count with profile, belt, achieved_by, awarded_by filters - Add GET /promotions/frequency returning counts by BJJBelt - Add getProfileTypeTotals to Query/Projected.hs and Query/Live.hs - Add getPromotionBeltTotals to Query/Projected.hs and Query/Live.hs - All endpoints support liveprojection flag
Merged
mariusgeorgescu
added a commit
that referenced
this pull request
Feb 21, 2026
* fixes * name filter * fix tag DeleteProfile action * wip * delete profile fix: wrong ref script * comment typo * KupoAtlas typo * KupoAtlas typo in cabal file * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * last fixes * kupo url in constants * k8s: add complete deployment docs (RO), annotate manifests, fix server Deployment (init wait-for-db, WAL-friendly mount); add architecture diagram; cleanup unused creds file * k8s: switch to Gateway API (Gateway + HTTPRoute); add Certificate for DNS-01 via GoDaddy ClusterIssuer; remove Ingress * docs(k8s): update to Gateway API flow – replace Ingress with Gateway/HTTPRoute + Certificate; update commands, troubleshooting, and architecture diagram * docs(k8s): document Gateway API enablement (GatewayClass, RBAC, Traefik args 80/443, svc targetPorts); explain traefik-gateway-rbac.yaml and gatewayclass-traefik.yaml; update troubleshooting and reset steps * k8s: cleanup manifests; remove duplicate cert-manager annotation from Gateway; add Traefik GatewayClass and RBAC; include server Query updates * k8s(server): switch liveness/readiness probes to HTTP GET /swagger-ui for stable 200 * splitted services * updated docs * fixed * refactoring libs * refactoring libs * refactor: reorganize project into distinct libraries with clean architecture 🏗️ Library Reorganization: - Renamed default library to 'onchain' for clarity - Created src/lib/ folder to organize all libraries - Moved all libraries under src/lib/ for better structure 📦 New Library Structure: - onchain: Plutus smart contracts and blockchain logic - webapi: Web infrastructure (Auth, Health, CORS) - chainsync: Generic chain synchronization utilities - offchain: Domain logic and supporting infrastructure 🔄 Module Movements: - Moved Utils.hs to offchain-lib (where it's most used) - Moved Storage.hs and Ingestion.hs to offchain-lib - Moved KupoClient.hs and KupoAtlas.hs to chainsync-lib - Moved all Onchain modules to onchain-lib - Moved WebAPI modules to webapi-lib 🔗 Dependency Updates: - Updated all library dependencies in cabal file - Fixed import paths and module references - Ensured clean dependency flow: chainsync → offchain → webapi → onchain 📚 Documentation Updates: - Updated README.md with new project structure - Added library architecture section with dependency flow - Updated detailed documentation with library descriptions ✅ Benefits: - Maximum reusability for generic components - Clean separation of concerns - Better maintainability and testability - Logical grouping of related modules All libraries and executables build successfully with the new structure. * wip * wip * wip * wip * wip * wip cleanup * wip cleanup * CLEANUP IMPORTS * doc update * docker compose update * update readyness * docker compose * cabal freeze * updated swagger path and deleted k8s * updated docker compose * postgressql * fix swagger dir * fix chainsync -> take policy from config * wip * wip adding sh to deployedscriptsctx * wip * wip chainsync * wip chainsync * wip chainsync * wip chainsync * wip chainsync * psql * craddle + semantic tokens * github actions * changes in dockerfiles moved copy of src in base * updated component diagram * selfhosted runner * add cabal freeze to base img * fix -systemd * wip * wip-1 * dev env udates * feat(query-api): add Count and Frequency endpoints for Profiles and Promotions APIs (#23) - Add GET /profiles/count with profile_type filter - Add GET /profiles/frequency returning counts by ProfileType - Add GET /promotions/count with profile, belt, achieved_by, awarded_by filters - Add GET /promotions/frequency returning counts by BJJBelt - Add getProfileTypeTotals to Query/Projected.hs and Query/Live.hs - Add getPromotionBeltTotals to Query/Projected.hs and Query/Live.hs - All endpoints support liveprojection flag * Memberships & Achievements & Oracle Hub Summary This set of changes delivers a major on-chain and off-chain upgrade focused on PlutusV3 performance, security hardening, and protocol feature expansion, alongside improved documentation, testing, and tooling. Key themes PlutusV3 token ID generation optimization (docs + code): Switched token ID derivation from the older PlutusV2-style approach (takeByteString 28 $ blake2b_256 + serialiseData . toBuiltinData) to PlutusV3-native builtins: blake2b_224 + integerToByteString, reducing execution units and improving efficiency. O(1) validation via output index optimization (perf + breaking): Replaced linear output scanning with indexed output lookup by passing output indices through redeemers. This reduces execution units but is a BREAKING CHANGE because redeemer structures changed, requiring redeployment. Security & architecture changes: Profiles are now permanent (profile deletion removed). Added datum/metadata size limits to mitigate DoS vectors. Tightened validator logic (e.g., removing redundant checks, consent-only simplification). Implemented and refined security audit fixes, including protections against interval “head-bypass” style attacks and multiple membership-related validation gaps. Major new protocol functionality: Introduced a full on-chain membership system (linked list/history/interval model, validator + policies, protocol types, redeemers). Added an Oracle Hub for dynamic protocol parameters (pause, fees, min lovelace, admin actions) without redeploying validators. Later release adds Achievements support (validator + award/accept flow), plus query API & storage support. Tooling, scripts, and testing improvements: Added/admin CLI improvements (notably offline CIP-57 blueprint generation). Expanded testnet population + exUnits testing scripts and reporting (including script size % of 16KB). Added malicious/edge-case tests, sequential scenario tests, and broad coverage/serialization property tests. Refactors & cleanup: Reduced redundancy, standardized redeemer construction, extracted shared helpers, improved config loading, made chain-sync network-agnostic, and cleaned dead code. Ongoing docs updates: architecture, changelog sections, security audit, developer guide/to-do tracking. * Release 0.3.1.9 – dynamic min ADA from oracle, docs, API versioning, and tooling (#30) * Changelog 0.3.1.8: unit test refactor, membership interval validation, protocolMinLovelace - Unit tests split into Achievement, Cleanup, Membership, Oracle, Promotion; Test.Fixtures and Test.Helpers added - AddMembershipIntervalReason and structured exceptions for add-interval; getFirstIntervalIdForMembershipNode; addMembershipIntervalTX pre-validation - Skeletons: txIsValidForSafeEra, safeEraTime Integer; protocolMinLovelace 10M - Admin, config, scripts, interaction Swagger updated Co-authored-by: Cursor <cursoragent@cursor.com> * Add Cursor rules: architecture, workflow, Haskell/Plutus, and operations Co-authored-by: Cursor <cursoragent@cursor.com> * fix(config,oracle): Correct TxBuilding typo, die for missing config, oracle O(1) output check Co-authored-by: Cursor <cursoragent@cursor.com> * chore: sync version to 0.3.1.8 and add versioning rule and release workflow Co-authored-by: Cursor <cursoragent@cursor.com> * docs(git-commit): align with versioning rule for version bumps Co-authored-by: Cursor <cursoragent@cursor.com> * docs(api): Set API version to 1.0.0 and add api-versioning rule Co-authored-by: Cursor <cursoragent@cursor.com> * feat(protocol): add dynamic min ADA from oracle and SafeOnchainLogic wrappers Co-authored-by: Cursor <cursoragent@cursor.com> * docs: Expand README/API/CLI, fix PUML typos, add regenerate_diagrams script * Fixes (#31) * Changelog 0.3.1.8: unit test refactor, membership interval validation, protocolMinLovelace - Unit tests split into Achievement, Cleanup, Membership, Oracle, Promotion; Test.Fixtures and Test.Helpers added - AddMembershipIntervalReason and structured exceptions for add-interval; getFirstIntervalIdForMembershipNode; addMembershipIntervalTX pre-validation - Skeletons: txIsValidForSafeEra, safeEraTime Integer; protocolMinLovelace 10M - Admin, config, scripts, interaction Swagger updated Co-authored-by: Cursor <cursoragent@cursor.com> * Add Cursor rules: architecture, workflow, Haskell/Plutus, and operations Co-authored-by: Cursor <cursoragent@cursor.com> * fix(config,oracle): Correct TxBuilding typo, die for missing config, oracle O(1) output check Co-authored-by: Cursor <cursoragent@cursor.com> * chore: sync version to 0.3.1.8 and add versioning rule and release workflow Co-authored-by: Cursor <cursoragent@cursor.com> * docs(git-commit): align with versioning rule for version bumps Co-authored-by: Cursor <cursoragent@cursor.com> * docs(api): Set API version to 1.0.0 and add api-versioning rule Co-authored-by: Cursor <cursoragent@cursor.com> * feat(protocol): add dynamic min ADA from oracle and SafeOnchainLogic wrappers Co-authored-by: Cursor <cursoragent@cursor.com> * docs: Expand README/API/CLI, fix PUML typos, add regenerate_diagrams script Co-authored-by: Cursor <cursoragent@cursor.com> * feat(chain-sync): Persist policy hex at startup and wipe only on policy change Co-authored-by: Cursor <cursoragent@cursor.com> * chore(rules): Fix doc link, update rule index, remove report; update validators config Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
mariusgeorgescu
added a commit
that referenced
this pull request
Feb 22, 2026
* fixes * name filter * fix tag DeleteProfile action * wip * delete profile fix: wrong ref script * comment typo * KupoAtlas typo * KupoAtlas typo in cabal file * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * wip chain sync * last fixes * kupo url in constants * k8s: add complete deployment docs (RO), annotate manifests, fix server Deployment (init wait-for-db, WAL-friendly mount); add architecture diagram; cleanup unused creds file * k8s: switch to Gateway API (Gateway + HTTPRoute); add Certificate for DNS-01 via GoDaddy ClusterIssuer; remove Ingress * docs(k8s): update to Gateway API flow – replace Ingress with Gateway/HTTPRoute + Certificate; update commands, troubleshooting, and architecture diagram * docs(k8s): document Gateway API enablement (GatewayClass, RBAC, Traefik args 80/443, svc targetPorts); explain traefik-gateway-rbac.yaml and gatewayclass-traefik.yaml; update troubleshooting and reset steps * k8s: cleanup manifests; remove duplicate cert-manager annotation from Gateway; add Traefik GatewayClass and RBAC; include server Query updates * k8s(server): switch liveness/readiness probes to HTTP GET /swagger-ui for stable 200 * splitted services * updated docs * fixed * refactoring libs * refactoring libs * refactor: reorganize project into distinct libraries with clean architecture 🏗️ Library Reorganization: - Renamed default library to 'onchain' for clarity - Created src/lib/ folder to organize all libraries - Moved all libraries under src/lib/ for better structure 📦 New Library Structure: - onchain: Plutus smart contracts and blockchain logic - webapi: Web infrastructure (Auth, Health, CORS) - chainsync: Generic chain synchronization utilities - offchain: Domain logic and supporting infrastructure 🔄 Module Movements: - Moved Utils.hs to offchain-lib (where it's most used) - Moved Storage.hs and Ingestion.hs to offchain-lib - Moved KupoClient.hs and KupoAtlas.hs to chainsync-lib - Moved all Onchain modules to onchain-lib - Moved WebAPI modules to webapi-lib 🔗 Dependency Updates: - Updated all library dependencies in cabal file - Fixed import paths and module references - Ensured clean dependency flow: chainsync → offchain → webapi → onchain 📚 Documentation Updates: - Updated README.md with new project structure - Added library architecture section with dependency flow - Updated detailed documentation with library descriptions ✅ Benefits: - Maximum reusability for generic components - Clean separation of concerns - Better maintainability and testability - Logical grouping of related modules All libraries and executables build successfully with the new structure. * wip * wip * wip * wip * wip * wip cleanup * wip cleanup * CLEANUP IMPORTS * doc update * docker compose update * update readyness * docker compose * cabal freeze * updated swagger path and deleted k8s * updated docker compose * postgressql * fix swagger dir * fix chainsync -> take policy from config * wip * wip adding sh to deployedscriptsctx * wip * wip chainsync * wip chainsync * wip chainsync * wip chainsync * wip chainsync * psql * craddle + semantic tokens * github actions * changes in dockerfiles moved copy of src in base * updated component diagram * selfhosted runner * add cabal freeze to base img * fix -systemd * wip * wip-1 * dev env udates * feat(query-api): add Count and Frequency endpoints for Profiles and Promotions APIs (#23) - Add GET /profiles/count with profile_type filter - Add GET /profiles/frequency returning counts by ProfileType - Add GET /promotions/count with profile, belt, achieved_by, awarded_by filters - Add GET /promotions/frequency returning counts by BJJBelt - Add getProfileTypeTotals to Query/Projected.hs and Query/Live.hs - Add getPromotionBeltTotals to Query/Projected.hs and Query/Live.hs - All endpoints support liveprojection flag * Memberships & Achievements & Oracle Hub Summary This set of changes delivers a major on-chain and off-chain upgrade focused on PlutusV3 performance, security hardening, and protocol feature expansion, alongside improved documentation, testing, and tooling. Key themes PlutusV3 token ID generation optimization (docs + code): Switched token ID derivation from the older PlutusV2-style approach (takeByteString 28 $ blake2b_256 + serialiseData . toBuiltinData) to PlutusV3-native builtins: blake2b_224 + integerToByteString, reducing execution units and improving efficiency. O(1) validation via output index optimization (perf + breaking): Replaced linear output scanning with indexed output lookup by passing output indices through redeemers. This reduces execution units but is a BREAKING CHANGE because redeemer structures changed, requiring redeployment. Security & architecture changes: Profiles are now permanent (profile deletion removed). Added datum/metadata size limits to mitigate DoS vectors. Tightened validator logic (e.g., removing redundant checks, consent-only simplification). Implemented and refined security audit fixes, including protections against interval “head-bypass” style attacks and multiple membership-related validation gaps. Major new protocol functionality: Introduced a full on-chain membership system (linked list/history/interval model, validator + policies, protocol types, redeemers). Added an Oracle Hub for dynamic protocol parameters (pause, fees, min lovelace, admin actions) without redeploying validators. Later release adds Achievements support (validator + award/accept flow), plus query API & storage support. Tooling, scripts, and testing improvements: Added/admin CLI improvements (notably offline CIP-57 blueprint generation). Expanded testnet population + exUnits testing scripts and reporting (including script size % of 16KB). Added malicious/edge-case tests, sequential scenario tests, and broad coverage/serialization property tests. Refactors & cleanup: Reduced redundancy, standardized redeemer construction, extracted shared helpers, improved config loading, made chain-sync network-agnostic, and cleaned dead code. Ongoing docs updates: architecture, changelog sections, security audit, developer guide/to-do tracking. * Changelog 0.3.1.8: unit test refactor, membership interval validation, protocolMinLovelace - Unit tests split into Achievement, Cleanup, Membership, Oracle, Promotion; Test.Fixtures and Test.Helpers added - AddMembershipIntervalReason and structured exceptions for add-interval; getFirstIntervalIdForMembershipNode; addMembershipIntervalTX pre-validation - Skeletons: txIsValidForSafeEra, safeEraTime Integer; protocolMinLovelace 10M - Admin, config, scripts, interaction Swagger updated Co-authored-by: Cursor <cursoragent@cursor.com> * Add Cursor rules: architecture, workflow, Haskell/Plutus, and operations Co-authored-by: Cursor <cursoragent@cursor.com> * fix(config,oracle): Correct TxBuilding typo, die for missing config, oracle O(1) output check Co-authored-by: Cursor <cursoragent@cursor.com> * chore: sync version to 0.3.1.8 and add versioning rule and release workflow Co-authored-by: Cursor <cursoragent@cursor.com> * docs(git-commit): align with versioning rule for version bumps Co-authored-by: Cursor <cursoragent@cursor.com> * docs(api): Set API version to 1.0.0 and add api-versioning rule Co-authored-by: Cursor <cursoragent@cursor.com> * feat(protocol): add dynamic min ADA from oracle and SafeOnchainLogic wrappers Co-authored-by: Cursor <cursoragent@cursor.com> * docs: Expand README/API/CLI, fix PUML typos, add regenerate_diagrams script Co-authored-by: Cursor <cursoragent@cursor.com> * Release 0.3.1.9 – dynamic min ADA from oracle, docs, API versioning, and tooling (#30) * Changelog 0.3.1.8: unit test refactor, membership interval validation, protocolMinLovelace - Unit tests split into Achievement, Cleanup, Membership, Oracle, Promotion; Test.Fixtures and Test.Helpers added - AddMembershipIntervalReason and structured exceptions for add-interval; getFirstIntervalIdForMembershipNode; addMembershipIntervalTX pre-validation - Skeletons: txIsValidForSafeEra, safeEraTime Integer; protocolMinLovelace 10M - Admin, config, scripts, interaction Swagger updated Co-authored-by: Cursor <cursoragent@cursor.com> * Add Cursor rules: architecture, workflow, Haskell/Plutus, and operations Co-authored-by: Cursor <cursoragent@cursor.com> * fix(config,oracle): Correct TxBuilding typo, die for missing config, oracle O(1) output check Co-authored-by: Cursor <cursoragent@cursor.com> * chore: sync version to 0.3.1.8 and add versioning rule and release workflow Co-authored-by: Cursor <cursoragent@cursor.com> * docs(git-commit): align with versioning rule for version bumps Co-authored-by: Cursor <cursoragent@cursor.com> * docs(api): Set API version to 1.0.0 and add api-versioning rule Co-authored-by: Cursor <cursoragent@cursor.com> * feat(protocol): add dynamic min ADA from oracle and SafeOnchainLogic wrappers Co-authored-by: Cursor <cursoragent@cursor.com> * docs: Expand README/API/CLI, fix PUML typos, add regenerate_diagrams script * feat(chain-sync): Persist policy hex at startup and wipe only on policy change Co-authored-by: Cursor <cursoragent@cursor.com> * chore(rules): Fix doc link, update rule index, remove report; update validators config Co-authored-by: Cursor <cursoragent@cursor.com> * Fixes (#31) * Changelog 0.3.1.8: unit test refactor, membership interval validation, protocolMinLovelace - Unit tests split into Achievement, Cleanup, Membership, Oracle, Promotion; Test.Fixtures and Test.Helpers added - AddMembershipIntervalReason and structured exceptions for add-interval; getFirstIntervalIdForMembershipNode; addMembershipIntervalTX pre-validation - Skeletons: txIsValidForSafeEra, safeEraTime Integer; protocolMinLovelace 10M - Admin, config, scripts, interaction Swagger updated Co-authored-by: Cursor <cursoragent@cursor.com> * Add Cursor rules: architecture, workflow, Haskell/Plutus, and operations Co-authored-by: Cursor <cursoragent@cursor.com> * fix(config,oracle): Correct TxBuilding typo, die for missing config, oracle O(1) output check Co-authored-by: Cursor <cursoragent@cursor.com> * chore: sync version to 0.3.1.8 and add versioning rule and release workflow Co-authored-by: Cursor <cursoragent@cursor.com> * docs(git-commit): align with versioning rule for version bumps Co-authored-by: Cursor <cursoragent@cursor.com> * docs(api): Set API version to 1.0.0 and add api-versioning rule Co-authored-by: Cursor <cursoragent@cursor.com> * feat(protocol): add dynamic min ADA from oracle and SafeOnchainLogic wrappers Co-authored-by: Cursor <cursoragent@cursor.com> * docs: Expand README/API/CLI, fix PUML typos, add regenerate_diagrams script Co-authored-by: Cursor <cursoragent@cursor.com> * feat(chain-sync): Persist policy hex at startup and wipe only on policy change Co-authored-by: Cursor <cursoragent@cursor.com> * chore(rules): Fix doc link, update rule index, remove report; update validators config Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> * Align develop with fixes: remove rules-alignment report, normalize EOF newlines Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…romotions APIs
Note
Introduces count and frequency queries to broaden the Query API surface and align Profiles/Promotions with existing Belts metrics.
GET /profiles/count,GET /profiles/frequency,GET /promotions/count,GET /promotions/frequency(all supportliveprojection)RestAPI.hs(profilesServer,promotionsServer) with filters forprofile_type,profile,belt,achieved_by,awarded_byQuery/Live.hs:getProfileTypeTotals,getPromotionBeltTotalsQuery/Projected.hs: SQL-basedgetProfileTypeTotals,getPromotionBeltTotals0.2.3.0documenting the new Query API endpointsWritten by Cursor Bugbot for commit 11fac46. This will update automatically on new commits. Configure here.